﻿var app = new Vue({
	el: '#app',
	extends:isLogin,
	components: {
		headers:header,
		navs:nav,
		footers: footer,
		login:login,
	},
	data: {
        bgImg:'img/PCindex/top1.jpg',
		navState:'品牌企业',
		topBuildCardData:'',//推荐企业
		newBuildCard:'',//最新网员数据
		keyWord:'',//搜索关键字
	},
	methods: {
		//header组件的搜索方法
		searchHeader: function(searchCtx) {
			
		},
		//获取推荐的企业名片
		getTopBuildCard:function(UnitCategory){
			var _this = this;
			if(!UnitCategory){
				UnitCategory = '';
			}
			var method = 'EntCard/GetTopEnterpriseCard';
			var param = {
				UnitCategory:'',
				PageSize:6,
			};
			xq.getUrl(method, param, function(res) {
				if(res.data) {
					var data = res.data;
					for(var i = 0;i < data.length;i++){
						if(data[i].Impression){
							data[i].Impression = data[i].Impression.split(',');
						}
						if(data[i].LogoPath){
							//data[i].LogoPath = xq.imgUrl + data[i].LogoPath;//后台已经拼凑
						}
					}
					_this.topBuildCardData = data;
				}
			});
		},
		//获取最新网员的名片
		getNewBuildCard:function(UnitCategory){
			var _this = this;
			if(!UnitCategory){
				UnitCategory = '';
			}
			var method = 'EntCard/GetNewEnterpriseCard';
			var param = {
				UnitCategory:UnitCategory,
				PageSize:4,
			};
			xq.getUrl(method, param, function(res) {
				if(res.data) {
					var data = res.data;
					for(var i = 0;i < data.length;i++){
						if(data[i].Impression){
							data[i].Impression = data[i].Impression.split(',');
						}
					}
					_this.newBuildCard = data;
				}
			});
		},
		//点击搜索
		search:function(){
			location.href = 'searchList.html?keyWord=' + this.keyWord;
		},
		//点击分类
		clickClass:function(event){
			var UnitCategory = '';
			var content = $(event.target).html();
			$(event.target).parents('li').addClass('cur').siblings().removeClass('cur');
			if(content){
				UnitCategory = content;
			}
//			var UnitCategory = $(event.target).
			this.getTopBuildCard(UnitCategory);
			this.getNewBuildCard(UnitCategory);
		},
		//跳转到企业名片
		toCompCard:function(CompCardId){
			localStorage.setItem('CompCardId',CompCardId);
			window.open('compCard.html','_blank');
		},
	},
	mounted: function() {
		this.getTopBuildCard();
		this.getNewBuildCard();
	},
	updated: function() {

	}
})